package com.hc.componentspringboot.interceptor;

import com.hc.componentspringboot.util.JwtUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 拦截器获取Token
 */
@Configuration
public class TokenInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(JwtUtil.checkTokenValid(request.getHeader("token"))){
            return true;
        }
        return false;
    }
}
